package com.job.ZhangMeng.Homework0711;

public class President {
    private String name;
    public static int number=1000;

    //创建实例并初始化
    private static President p=new President();//自创建私有的静态的实例p

    //仅创建实例但不初始化
    //private static President p;

    public static President getInstance()//公开的只读方法
    {
        //if(p==null)
            //p=new President();
        return p;
    }

    public String getName(){return name;}
    public void setName(String name){ this.name = name; }

    //私有构造方法，禁止其他类创建对象
    private President(){}
    private President(String n){this.name=n;}
}
